﻿@using Website.CRUDServices
@using Location = Website.Models.Domain.Location
@using Profile = Website.Models.Domain.Profile
@using Region = Website.Models.Domain.Region
@model Activity
@{
    this.ViewBag.Title = "Forretningsudvikling";
    this.Layout = "~/Views/_Shared/_Layout.cshtml";
    var Regions = this.ViewData["Regions"] as List<Region>;
    var allTopics = this.ViewData["DiscussionTopics"] as List<Topic>;
    var Projects = this.ViewData["Projects"] as List<Project>;
    var Profiles = this.ViewData["Profiles"] as Website.Models.ViewModels.ProfilesView;
    var BDActivity = this.Model as Activity;
    Guid otherId = Guid.Empty;

    // errorhandling
    var errorMsg = new HtmlString(string.Empty);
    if (this.ViewData["ErrorMessage"] != null)
    {
        errorMsg = this.ViewData["ErrorMessage"] as HtmlString;
    }

}

@Html.Partial("~/Views/_Shared/LogView.cshtml", Model.ID)

<script type="text/javascript">
    //toggle script
    function toggle(id) {
        if (document.getElementById(id).style.display == 'none' || document.getElementById(id).style.display == "") {
            document.getElementById(id).style.display = 'block';
        } else {
            document.getElementById(id).style.display = 'none';
        }
    }
</script>
<!--toggle additional comments -->
@if (BDActivity.BDA.AdditionalComments != null && BDActivity.BDA.AdditionalComments != "")
{
    <script>
        $(function () {
            toggle('Comments_holder');
        });
    </script>
}
<!--toggle topic elaboration -->
@foreach (Topic top in allTopics.Where(x => (BDActivity.BDA.Topics ?? new Guid[0]).Contains(x.ID)))
{
    if (top.Title == "Andet")
    {
    <script>
        $(function () {
            toggle('andet_holder');
        });
    </script>
    }

}




@*// date*@
<fieldset class="chosenFields">
    <legend>Dato</legend>
    @if(BDActivity.TimeOfActivity.HasValue){
@BDActivity.TimeOfActivity.Value.ToShortDateString()}</fieldset>

@*// location*@
<fieldset class="chosenFields">
    <legend>Lokation*</legend>
    @foreach (Location loc in Profiles.Locations.OrderBy(x => x.Name))
    {
        if (loc.ID == BDActivity.Location)
        {
        @loc.Name <br />
        }
    }
</fieldset>

@*// ownerProjects chooser*@
<fieldset class="chosenFields"><legend>Alle projekter tilknyttet</legend>

    @foreach (Project proj in Projects.Where(x => (BDActivity.OwnerProjects ?? new Guid[0]).Contains(x.ID)))
    {
        @proj.Name<br />
    }
</fieldset>

@*// profiles chooser*@
<fieldset class="chosenFields"><legend>Profiler</legend>

    @foreach (Profile prof in Profiles.Profiles.Where(x => (BDActivity.Attendees ?? new Guid[0]).Contains(x.ID)))
    {
        @prof.Name<br />
    }
</fieldset>


@*// talks chooser*@
<fieldset class="chosenFields"><legend>Specificeret snak</legend>
    @foreach (Topic top in allTopics.Where(x => (BDActivity.BDA.Topics ?? new Guid[0]).Contains(x.ID)))
    {
        @top.Title<br />
    }
</fieldset>

@*// field for specifying "andet"*@
    <div class="formEntry open_hidden" id="andet_holder">
        <fieldset class="chosenFields"><legend>Specificéring af "andet"</legend>
        @BDActivity.BDA.TopicElaboration</fieldset>
    </div>





@*// status*@
<fieldset class="chosenFields"><legend>Beskrivelse</legend>

    @BDActivity.Commentary</fieldset>

@*// additional comments*@

<div class="formEntry open_hidden" id="Comments_holder">
    <fieldset class="chosenFields"><legend>Yderligere kommentarer</legend>
   @BDActivity.BDA.AdditionalComments</fieldset>
</div>


